package br.com.foxline.atlasmobile.request;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import br.com.foxline.atlasmobile.dao.AnnexDao;
import br.com.foxline.atlasmobile.dao.ImovelDao;
import br.com.foxline.atlasmobile.entities.Annex;
import br.com.foxline.atlasmobile.entities.Imovel;
import br.com.foxline.atlasmobile.entities.Proprietario;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class ExportData {
	
	private DateFormat fmt = new SimpleDateFormat("dd/MM/yyyy");
	
	private ImovelDao imovelDao;
	
	private AnnexDao annexDao;
	
	private Context contexto;
	
	public ExportData(Context contexto){
		this.contexto = contexto;
	}
	
	
	
	public  void ImovelJson(Imovel imovel){
		List<Annex> list = new ArrayList<Annex>();
		
		imovel.setCroquiImovel(null);
		imovel.setCroquiTerreno(null);
		for (Proprietario p : imovel.getProprietarios()) {
				p.setImovel(null);
		}
		
		for (Annex annex : imovel.getAnnex()) {
			annex.setId(null);
			annex.setImovel(null);
			list.add(annex);
		}
		
		imovel.setAnnex(list);
		Gson gson = new GsonBuilder().setDateFormat("dd/MM/yyyy").create();
		
		String data = gson.toJson(imovel);
		
//		RequestWebJSON json = new RequestWebJSON(contexto);
//		json.execute(data);
		
	}	

}
